﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    @V5.Html.Partial("User/_ChkUser")
    <title>@V5.Config.View["SiteTitle"]</title>
    <meta name="Keywords" content="网络购物，网上超市，网上购物，购物，网上商店，购物商城,购物网，超市网,世博会门票购买" />
    <meta name="Description" content="用鼠标逛超市，不用排队，方便实惠送上门，网上购物新生活。" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link type="text/css" rel="stylesheet" href="/@V5.Config.TemplatePath/css/index.css"/>
    <link type="text/css" rel="stylesheet" href="/@V5.Config.TemplatePath/css/product_detail.css"/> 
    <script src="/@V5.Config.TemplatePath/javascript/jquery.min.js" type="text/javascript"></script>
    <script src="/@V5.Config.TemplatePath/javascript/Comon.js" type="text/javascript" charset="UTF-8"></script> 
    <script src="/@V5.Config.TemplatePath/javascript/loading/loading_source.js" type="text/javascript" charset="UTF-8"></script>
    @V5.Html.Partial("includes/tView")
</head>
<body>
    @*@V5.Html.Partial("includes/header")*@
    @{
        var user = (V5_Model.ModelGZUser)Session["isLogin"];  
        }
    <div class="wrap">
        @V5.Html.Partial("User/_Menu")
        <div class="right_content">
            <div class="crumb">
                <a class="home" href="/index.aspx" target="_blank">首页</a> > <span>个人中心</span> &nbsp;&nbsp;&nbsp;<a href="/loginOut.aspx" style="background:none;color:Red;font-weight:bold">退出登录</a></div>
           @* <div class="personal_center">
                <div class="fleft">
                    <img src="images/tx.jpg" width="120" height="120" /></div>
                <div class="right">
                    <dl class="user_infos">
                        <dt><strong>您好，@user.CustomName</strong></dt>
                        <dd>
                            <li>订单数（<strong>0</strong>）</li>
                            <li>等待收货订单（<strong>0</strong>）</li>
                            <li>等待评价商品（<strong>0</strong>）</li>
                            <li>当前积分：<strong>0</strong>&nbsp;分</li>
                            <li>账户余额：<strong>￥0</strong></li>
                            <li>冻结金额：<strong>￥0</strong></li>
                        </dd>
                    </dl>
                </div>
                <div class="clearfix">
                </div>
            </div>*@


            @{
                int p = (Request["p"] + string.Empty) == "" ? 1 : int.Parse(Request["p"] + string.Empty);
                var str = Request["str"] + string.Empty;
                
                int index = 1;
                if (p < 1)
                {
                    p = 1;
                }

                if (p > 1)
                {
                    index = ((p - 1) * 10) + 1;
                }
                
                System.Data.DataTable dt = new V5_EShop._Class.BLL.GZ.BLLGZProductOrder().GetList(" CustomID = '" + user.ID + "' "+(str!="" ?" and BillNo like '%"+str+"%'":"")+" order by CreateDatetime desc").Tables[0];
                System.Data.DataTable dtp = new V5_EShop._Class.BLL.GZ.BLLGZProductOrder().GetListByPage(" CustomID = '" + user.ID + "'" + (str != "" ? " and BillNo like '%" + str + "%'" : ""), " CreateDatetime desc", index, p * 10).Tables[0];

                decimal orderMoney = 0;
                
                }

            <div class="personal_box">
                <h3>
                    我的订单</h3>
                <div class="personal_detail">
                    <div style="margin-bottom:10px">订单号：<input id="orderKey" type="text" value="@str" /><input id="btn_search" type="button" value="搜索" /></div>
                    <table width="100%" border="0" cellspacing="1" cellpadding="0" class="data">
                        <thead>
                            <tr>
                                <th>
                                    订单号
                                </th>
                                <th>
                                    创建时间
                                </th>
                                 <th>
                                    订单金额
                                </th>
                                 <th>
                                    是否积分兑换
                                </th>
                                <th>
                                    当前状态
                                </th>  
                                <th>
                                    操作
                                </th>
                            </tr>
                        </thead>

                        @if(dtp!=null&&dtp.Rows.Count>0)
                        {
                            foreach(System.Data.DataRow item in dtp.Rows)
                            {
                            <tr id="parent_@(item["ID"])">
                                <td>
                                    @item["BillNo"]
                                </td>
                                <td>
                                    @item["CreateDatetime"]
                                </td>
                                <td id="order_parent_momey_@(item["ID"])">
                                    &nbsp;
                                </td>
                                <td >
                                   @Html.Raw((item["paystatus"] + string.Empty) == "0" ? "否" : "<font style='color:red'>是</font>")
                                </td>
                                <td>
                                    @((item["Status"]+string.Empty).Trim() == ""?"正常":"锁定") 
                                </td>
                               
                                <td>
                                    <a href="javascript:;" data-id="@item["ID"]" class="showDetail" >查看明细</a>&nbsp;&nbsp;&nbsp;
                                    <a href="javascript:;" data-id="@item["ID"]" class="DelParentOrder">删除</a>
                                </td>
                            </tr> 
                            <tr id="detail_@(item["ID"])"  style="display:none">
                                <td colspan="4" align="right" style=" border-bottom:3px solid #666;">

                                    @{
                                        
                                        System.Data.DataTable dt2 = new V5_EShop._Class.BLL.GZ.BLLGZProductOrderItem().GetList(" ParentID='" + item["ID"] + "'").Tables[0];

                                         V5_EShop._Class.Model.ModelGZProduct ItemModel = new V5_EShop._Class.Model.ModelGZProduct();
                                        
                                        } 
                                    @if(dt2!=null&&dt2.Rows.Count>0)
                                    {
                                     <table width="98%" border="0" cellspacing="1" cellpadding="0" class="data">
                                        <thead>
                                            <tr>
                                                <th>
                                                    产品名称
                                                </th>
                                                <th>
                                                    单价
                                                </th>
                                                <th>
                                                    数量
                                                </th> 
                                                <th>
                                                    金额
                                                </th>
                                                <th>
                                                    操作
                                                </th>
                                            </tr>
                                        </thead>
                                         
                                        @foreach(System.Data.DataRow item2 in dt2.Rows)
                                        {
                                            ItemModel = new V5_EShop._Class.BLL.BLLGZProduct().GetModel(Guid.Parse(item2["ProductID"] + string.Empty));
                                            
                                            if(ItemModel==null){ 
                                                continue;
                                            }

                                            orderMoney += decimal.Parse(item2["OrderMoney"]+string.Empty);
                                            
                                        <tr id="detail_c_@(item2["ID"])" >
                                            <td title="@ItemModel.ProductName" style="width:300px">
                                                @{
                                                    if (ItemModel.ProductName.Length > 30)
                                                    {
                                                        @(ItemModel.ProductName.Substring(0, 30)) 
                                                    }
                                                    else{
                                                        @(ItemModel.ProductName)
                                                    } 
                                                }
                                            </td>
                                            <td id="edt_s_p_@(item2["ID"])">
                                                @decimal.Parse(item2["OrderPrice"]+string.Empty).ToString("0.00")
                                            </td>
                                            <td id="edt_s_@(item2["ID"])">
                                                @(((item2["OrderNumber"]+string.Empty).Split('.')[0]))
                                            </td>
                                            <td id="edt_e_@(item2["ID"])" style="display:none"> 
                                                @Html.TextBox("edt_t_"+item2["ID"], (((item2["OrderNumber"]+string.Empty).Split('.')[0])))
                                                <a href="javascript:;"  data-id="@item2["ID"]" class="SaveEdtItemInfo">保存</a>
                                                <a href="javascript:;"  data-id="@item2["ID"]" class="CancelEdtItemInfo">取消</a>
                                            </td>
                                            <td id="edt_s_m_@(item2["ID"])">
                                                @item2["OrderMoney"]
                                            </td> 
                                             <td id="item_contorl_@(item2["ID"])">
                                                 <a href="javascript:;"  data-id="@item2["ID"]" class="EdtItemInfo">编辑</a>&nbsp;&nbsp;&nbsp;
                                                 <a href="javascript:;" data-id="@item2["ID"]" class="DelChildOrder">删除</a>
                                            </td>  
                                        </tr>  
                                        } 
                                    </table>
                                         <input type="hidden" id="h_total_order_money_@(item["ID"])" class="total_order_money" data-id="@(item["ID"])" value="@orderMoney"   />
                                    }
                                </td>
                            </tr>
                            @*<tr >
                                <td colspan="4" style="border:0;height:10px">
                                </td>
                            </tr>*@
                            }
                        }
                    </table>
                </div>
                <div class="pagelist">
                
                @if (dt != null && dt.Rows.Count > 0)
                {
                    int page = int.Parse(Math.Ceiling((decimal.Parse(dt.Rows.Count.ToString())/10)).ToString("0"));
                    var url = "/index.aspx?t=user/mybill";
                    if (str != "")
                    {
                        url += "&str="+str; 
                    }
                    
                    for (int q = 1; q <= page; q++)
                    {
                        if (q == p)
                        {
                            <span class="page_cur">@q</span>
                        }
                        else
                        {
                            url += "&p="+q;
                            <a href="@url">@q</a>
                        }
                    
                    }
                    
                } 
                </div>

            </div>
        </div>
        <div class="clearfix">
        </div>
        <div class="mt10">
        </div>
    </div>
   @* @V5.Html.Partial("includes/Footer")*@
    <!--回顶部 -->
</body>
</html>

<script>
    var shopDetail = function () {
        $(".showDetail").bind("click", function () {
            var t = $("#detail_" + $(this).attr("data-id"));
            
            if (t.is(":hidden")) {
                t.show();
            }
            else {
                t.hide();
            }
        });
    };

    $(function () {

        shopDetail();

        $("#btn_search").bind("click", function () {
            var orderKey = $("#orderKey").val();

            window.location.href = '/index.aspx?t=user/mybill&str=' + orderKey;

        }); 

        $(".DelParentOrder").bind("click", function () {
            if (confirm("删除后将不能回复！确认删除？")) {
                showLoading();
                var id = $(this).attr("data-id");
                $.ajax({
                    type: "POST",
                    url: "/OrderModAction.aspx",
                    data: "ID=" + id + "&type=0",
                    success: function (data) {
                        if (data == "0") {
                            $("#parent_" + id).remove();
                            $("#detail_" + id).remove();
                            msg("删除成功！");
                        }
                        else {
                            msg(data);
                        }
                    },
                    complete: function () {
                        hideLoading();
                    }
                });
            }
        });

        $(".DelChildOrder").bind("click", function () {
            if (confirm("删除后将不能回复！确认删除？")) {
                var id = $(this).attr("data-id");
                showLoading();
                $.ajax({
                    type: "POST",
                    url: "/OrderModAction.aspx",
                    data: "ID=" + id + "&type=1",
                    success: function (data) {
                        if (data == "0") {
                            $("#detail_c_" + id).remove();
                            msg("删除成功！");
                        }
                        else {
                            msg(data);
                        }
                    },
                    complete: function () {
                        hideLoading();
                    }
                });
            }
        });

        $(".EdtItemInfo").bind("click", function () {
            var id = $(this).attr("data-id");

            $("#item_contorl_" + id + " a").hide();
            $("#edt_s_" + id).hide();
            $("#edt_e_" + id).show();
        });

        $(".CancelEdtItemInfo").bind("click", function () {

            var id = $(this).attr("data-id");

            $("#item_contorl_" + id + " a").show();
            $("#edt_s_" + id).show();
            $("#edt_e_" + id).hide();
        });


        $(".SaveEdtItemInfo").bind("click", function () {

            var id = $(this).attr("data-id");
            var amount = $("#edt_t_" + id);

            if (amount.val() == "") {
                amount.focus();
                msg("请输入数量");
                return;
            }

            try {
                if (parseInt(amount.val()) < 1) {
                    amount.focus();
                    msg("数量必须大于1！");
                    return;
                }
                if (parseInt(amount.val()) == NaN) {
                    amount.focus();
                    msg("必须输入数字！");
                    return;
                }
            } catch (ex) {

                amount.focus();
                msg("必须输入数字！");
                return;
            }

            showLoading();
            $.ajax({
                type: "POST",
                url: "/OrderModAction.aspx",
                data: "ID=" + id + "&type=2" + "&amount=" + amount.val(),
                success: function (data) {
                    if (data == "0") {
                        $("#item_contorl_" + id + " a").show();
                        $("#edt_s_" + id).html(amount.val()).show();
                        $("#edt_s_m_" + id).html(parseFloat($("#edt_s_p_" + id).html()) * parseFloat(amount.val()));
                        $("#edt_e_" + id).hide();
                        msg("编辑成功！");
                    }
                    else {
                        msg(data);
                    }
                },
                complete: function () {
                    hideLoading();
                }
            });


        });



        $(".total_order_money").each(function () {
            $("#order_parent_momey_" + $(this).attr("data-id")).html($(this).val());
        });
    });
</script> 